package com.seven.good.controller;

import com.github.pagehelper.PageInfo;
import com.seven.good.config.MobileAuthentication;
import com.seven.good.dto.BidRecordDTO;
import com.seven.good.dto.GoodConditionDto;
import com.seven.good.enums.GoodStateEnum;
import com.seven.good.enums.StatusCodeEnum;
import com.seven.good.exception.GoodException;
import com.seven.good.exception.GoodNotFoundException;
import com.seven.good.exception.ServiceException;
import com.seven.good.pojo.*;
import com.seven.good.service.*;
import com.seven.good.util.SendMail;
import com.seven.good.util.WebSourceToFileUtil;

import com.seven.logproducer.annotation.LogAnno;
import com.seven.logproducer.enums.LogTypeEnum;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@CrossOrigin
public class GoodController {

    @Autowired
    GoodService goodService;

    @Autowired
    GoodTypeService goodTypeService;

    @Autowired
    private GoodStatusService goodStatusService;

    @Autowired
    private UserConnectionService userConnectionService;

    @Autowired
    private SmsremindService smsremindService;

    @Autowired
    private BidRecordService bidRecordService;

    @Autowired
    private GoodPicturesService goodPicturesService;

    @Autowired
    private UserService userService;

    @Autowired
    private SendMail sendMail;

    @Autowired
    private OrdersService ordersService;


    @LogAnno(logType = LogTypeEnum.OPERATE_LOG,msg = "首页")
    @ApiOperation("获取推荐，并返回首页")
    @GetMapping("/index/{cond}")
    public ModelAndView getRecommendGood(@PathVariable Integer cond){

        ModelAndView mv = new ModelAndView("index");

        List<Good> recommends = null;
        HomePage onetheme = null;
        Good exgood = null;

        try {
            onetheme = getRandomeTheme();
            recommends = listRecommends(cond);
            exgood = getBestValueGood();

            mv.addObject("cond",cond);
            mv.addObject("recommends",recommends);
            mv.addObject("onetheme",onetheme);
            mv.addObject("exgood",exgood);

        } catch (GoodNotFoundException e) {
             mv.setViewName("auctionerror");
             mv.addObject("msg",e.getMessage());
        }
        return mv;
    }

    /**
     * @Description：按条件获取推荐的商品列表
     * @Author: ytj
     * @param: type 1:根据围观数，2：根据报名数，3：根据竞拍数
     * @return List<Good> 推荐商品列表
     * @exception: GoodNotFoundException
     * @CreateDate:  19/10/19
     */
    public List<Good> listRecommends(Integer type){
        try {
            if(type==1){
                return goodService.listGoodsByCircuseeNo();
            }else if (type==2){
                return goodService.listGoodsBySignUpNo();
            }else {
                return goodService.listGoodsByBidNo();
            }
        } catch (Exception e) {
            throw new GoodNotFoundException("商品推荐列表出现异常");
        }
    }

    /**
     * @Description：获取一个随机的主题
     * @Author: ytj
     * @return HomePage 主题（ThemeEnum.OneThemePage）
     * @exception: GoodNotFoundException
     * @CreateDate:  19/10/19
     */
    public HomePage getRandomeTheme(){
        try {
            return goodService.getOneTheme();
        } catch (Exception e){
            throw new GoodNotFoundException("主题推荐列表出现异常");
        }
    }

    /**
     * @Description：获取价格最高商品
     * @Author: ytj
     * @return Good 商品
     * @exception: GoodNotFoundException
     * @CreateDate:  19/10/23
     */
    public Good getBestValueGood(){
        try {
            return goodService.getExGood();
        } catch (Exception e){
            throw new GoodNotFoundException("价值最大物品出现异常");
        }
    }

    /**
     * @ Description   :  根据商品类型获取当天正在拍卖和已拍卖的商品列表
     * @ Author        :  lee
     * @ param        : [goodType, currentPage：商品类型id，当前页]
     * @ return       : org.springframework.web.servlet.ModelAndView
     * @ exception    :
     * @ CreateDate    :  2019/10/17 17:04
     */
    @RequestMapping("/today")
    public ModelAndView showToday(@RequestParam(name = "goodType",defaultValue = "1") Integer goodType,
                                  @RequestParam(name = "currentPage",defaultValue = "1") Integer currentPage){
        ModelAndView modelAndView = new ModelAndView("todaylist");
        List<Good> goods = null;
        //service异常，good为null，避免thymeleaf的NPE，到异常页面
        try {
            goods = goodService.listGoodsByTypeOnToday(goodType,currentPage);
        } catch (ServiceException e) {
            e.printStackTrace();
            modelAndView.setViewName("error");
            return modelAndView;
        }
        PageInfo pageInfo = new PageInfo(goods);
        modelAndView.addObject("pageInfo",pageInfo);
        modelAndView.addObject("goodType",goodType);
        return modelAndView;
    }

    /**
     * @ Description   :  根据传入的条件获取商品列表，商品依次包括正在拍卖，未拍卖，流拍和成交
     * @ Author        :  lee
     * @ param        : [currentPage：当前页]
     * @ return       : org.springframework.web.servlet.ModelAndView
     * @ exception    :
     * @ CreateDate    :  2019/10/17 20:04
     */
    @RequestMapping("/goodlist")
    public ModelAndView showGoodList(@RequestParam(name = "currentPage",defaultValue = "1") Integer currentPage,
                                     Integer[] goodStates,
                                     GoodConditionDto condition){
        ModelAndView modelAndView = new ModelAndView("goodlist");
        Integer gtid;
        GoodType goodType;
        List<Good> goods = null;
        //防止NPE
        if (condition == null) {
            condition = new GoodConditionDto();
        }
        if(goodStates==null||goodStates.length==0){
            //正在拍卖、即将拍卖、流拍、成交
            Integer[] states = {GoodStateEnum.TO_AUCTION.getCode(), GoodStateEnum.AUCTIONING.getCode(),
                    GoodStateEnum.ABORTIVE.getCode(),GoodStateEnum.KNOCK_DOWN.getCode()};
            condition.setGoodStates(states);
        }else{
            condition.setGoodStates(goodStates);
        }
        if((gtid=condition.getGoodType()) != null &&
                (goodType = goodTypeService.getGoodTypeByGtid(gtid)) != null){
            modelAndView.addObject("goodTypeTitle",goodType.getTitle());
        }else{
            modelAndView.addObject("goodTypeTitle","搜索结果");
        }
        try {
            goods = goodService.listGoodsByCondition(condition, currentPage);
        } catch (ServiceException e) {
            e.printStackTrace();
            modelAndView.setViewName("error");
            return modelAndView;
        }
        PageInfo pageInfo = new PageInfo(goods);
        modelAndView.addObject("pageInfo",pageInfo);
        modelAndView.addObject("condition",condition);
        return modelAndView;
    }


    /**
     * @ Description   :  返回商品上传页面
     * @ Author        :  lee
     * @ param        : []
     * @ return       : org.springframework.web.servlet.ModelAndView
     * @ exception    :
     * @ CreateDate    :  2019/10/25 14:18
     */
    @RequestMapping("/upload")
    public ModelAndView uploadGood(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("goodupload");
        return modelAndView;
    }

    /**
     * @ Description   :  返回所有的商品列表，没查到到数据库异常返回null
     * @ Author        :  lee
     * @ param        : []
     * @ return       : java.util.List<com.seven.good.pojo.GoodType>
     * @ exception    :
     * @ CreateDate    :  2019/10/25 14:19
     */
    @RequestMapping("/typelist")
    @ResponseBody
    public List<GoodType> getAllGoodTypes(){
        List<GoodType> goodTypes = null;
        try {
            goodTypes = goodTypeService.listAllGoodTypes();
        } catch (ServiceException e) {
            e.printStackTrace();
            return null;
        }
        return goodTypes;
    }

    /**
     * @ Description   :  商品基本信息上传到数据库，不包括文件；返回信息带商品id
     * @ Author        :  lee
     * @ param        : [good, durationTime, session]：[前端封装的商品对象，持续时间（单位h），springsession获取上传人id]
     * @ return       : java.lang.Object
     * @ exception    :
     * @ CreateDate    :  2019/10/25 14:40
     */
    @LogAnno(logType = LogTypeEnum.OPERATE_LOG,msg = "上传商品")
    @RequestMapping("/doupload")
    @ResponseBody
    public Object doUpload(Good good, Integer durationTime){
        Map<String,String> result = new HashMap<String, String>();
        Integer gid;
        Integer publisher;
        Long durationMillSeconds;
        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
        HttpSession session = ((ServletRequestAttributes) requestAttributes).getRequest().getSession();
        if (good == null) {
            result.put("code",StatusCodeEnum.DATAERROR.getCode());
            result.put("message","商品数据未填写");
            return result;
        }
        if((publisher = (Integer) session.getAttribute("userId")) == null){
            result.put("code",StatusCodeEnum.DATAERROR.getCode());
            result.put("message","用户信息缺失");
            return result;
        }else {
            good.setPublisher(publisher);
        }
        if (durationTime != null && durationTime >=1 && durationTime<=24)
            durationMillSeconds = Long.valueOf(durationTime) * 3600 * 1000;
        else {
            result.put("code",StatusCodeEnum.DATAERROR.getCode());
            result.put("message","时长设置错误");
            return result;
        }
        try {
            gid = goodService.insertGoodAndGetGid(good,durationMillSeconds);
            result.put("gid",gid+"");
            result.put("code",StatusCodeEnum.SUCCESS.getCode());
            result.put("message",StatusCodeEnum.SUCCESS.getDescription());
        } catch (GoodException e) {
            e.printStackTrace();
            result.put("code",StatusCodeEnum.DATAERROR.getCode());
            result.put("message",e.getMessage());
            return result;
        } catch (ServiceException  e){
            e.printStackTrace();
            result.put("code",StatusCodeEnum.ERROR.getCode());
            result.put("message","系统错误，请稍后再试");
            return result;
        }
        return result;
    }

    /**
     * @ Description   :  商品有关文件上传
     * @ Author        :  lee
     * @ param        : [gid, cover, thumbnails, showImages]：[商品id，封面，缩略图，展示图]
     * @ return       : java.lang.Object
     * @ exception    :
     * @ CreateDate    :  2019/10/25 14:45
     */
//    @LogAnno(logType = LogTypeEnum.OPERATE_LOG,msg = "上传商品图片")
    @RequestMapping("/fileupload")
    @ResponseBody
    public Object fileUpload(Integer gid, MultipartFile cover,
                              MultipartFile[] showImages){
        Map<String,String> result = new HashMap<String, String>();
        String coverPath = null;
        if (gid == null) {
            result.put("code",StatusCodeEnum.NOTFOUND.getCode());
            result.put("message","该商品还未创建成功");
            return result;
        }
        //没有文件则返回
        if (cover == null && (showImages == null || showImages.length==0)) {
            result.put("code",StatusCodeEnum.NOTFOUND.getCode());
            result.put("message","没有接收到文件信息");
            return result;
        }
        //预置成功信息开头和编码
        result.put("code",StatusCodeEnum.SUCCESS.getCode());
        result.put("success","");
        //优先级 封面>展示图
        if (cover != null) {
            try {
                coverPath = WebSourceToFileUtil.toFile(cover);
                goodService.updateUrlByGid(coverPath,gid);
                result.put("success",result.get("success")+"封面上传成功;");
            } catch (IOException e) {
                e.printStackTrace();
                result.put("code",StatusCodeEnum.ERROR.getCode());
                result.put("message","封面上传服务器失败，请与管理员联系");
                return result;
            } catch (ServiceException e) {
                e.printStackTrace();
                result.put("code",StatusCodeEnum.ERROR.getCode());
                result.put("message","封面上传失败，请与管理员联系");
                return result;
            }
        }
        /*if (thumbnails != null) {
            Integer size = thumbnails.length > 5 ? 5 : thumbnails.length;
            try {
                for (int i = 0; i < size; i++) {
                    String filePath = WebSourceToFileUtil.toFile(thumbnails[i], "thumbnails");
                }
            } catch (IOException e) {
                e.printStackTrace();
                result.put("code",StatusCodeEnum.ERROR.getCode());
                result.put("message","缩略图上传服务器失败，请与管理员联系");
                return result;
            }
        }*/
        if (showImages != null && showImages.length != 0) {
            GoodPictures goodPictures = new GoodPictures();
            goodPictures.setGid(gid);
            Integer size = showImages.length > 5 ? 5 : showImages.length;
            try {
                for (int i = 0; i < size; i++) {
                    String filePath = WebSourceToFileUtil.toFile(showImages[i]);
                    goodPictures.setPic(filePath);
                    goodPicturesService.insertPicture(goodPictures);
                }
                result.put("success",result.get("success")+"展示图片上传成功;");
            } catch (IOException e) {
                e.printStackTrace();
                result.put("code",StatusCodeEnum.ERROR.getCode());
                result.put("message","展示图上传失败，请与管理员联系");
                return result;
            } catch (ServiceException e) {
                e.printStackTrace();
                result.put("code",StatusCodeEnum.ERROR.getCode());
                result.put("message","展示图片上传失败，请与管理员联系");
                return result;
            }
        }
        return result;
    }

    /**
    * @Description: 根据商品id查询商品信息并计算倒计时秒数，跳转页面，显示所有商品信息
    * @Param:  gid 商品id
    * @return:  modelandview
    * @Author: 王胜奔
    * @Date: 2019/10/16 11:59
    * Version: 1.0
    */
    @LogAnno(logType = LogTypeEnum.OPERATE_LOG,msg="拍品详情页")
    @RequestMapping("/show")
    @ResponseBody
    public Map showGoodDetail(Integer gid){
        Map map = new HashMap();
        try {
            Good good=goodService.getGoodByGid(gid);
            //点进来就更新围观人数
            goodService.modifyCircuseeNoByGid(gid);
            //出价次数和当前价显示
            int bidNo = 0;
            int currentPrice = 0;
            BidRecordDTO bidRecordDTO=bidRecordService.getBidRecored(gid);
            try {
                bidNo = bidRecordDTO.getBidNo();
                //System.out.println(bidNo);
                List<BidRecord>bidRecords=bidRecordDTO.getBidRecords();
                if (bidRecords == null || bidRecords.size()<=0){
                    currentPrice = good.getStartPrice().intValue();
                }else {
                    currentPrice=bidRecords.get(0).getBidPrice();
                }
            } catch (Exception e) {
                currentPrice=good.getStartPrice().intValue();
            }


            //出价次数
            //int bidNo=bidRecordService.getBuyRecordByGid(1);
            //当前价显示
            //List<BidRecord> bidRecords=bidRecordService.getBidRecoredsByGid(1);
            //int currentPrice=bidRecords.get(0).getBidPrice();

            if(good.getGoodState()==2){ //已开拍
                //拍卖时间=结束时间-当前时间
                long end=good.getEndTime().getTime();//获取数据库拍卖结束时间，转为毫秒数
                long time=new Date().getTime();//获取当前系统时间转为毫秒数
                long date=(end-time)/1000;//转为秒数传到前端
                map.put("date",date);
            }
            if(good.getGoodState()==1){
                //开始时间-当前时间
                long start=good.getStartTime().getTime();//获取数据库拍卖开始时间，转为毫秒数
                long time=new Date().getTime();//获取当前系统时间转为毫秒数
                long date=(start-time)/1000;//转为秒数传到前端
                map.put("date",date);
            }
            String goodSatusType=goodStatusService.getGoodStateType(good.getGoodState());//商品状态类型
            map.put("currentPrice",currentPrice);//当前价格
            map.put("bidNo",bidNo);//出价次数
            map.put("goodStatusType",goodSatusType);//商品状态
            map.put("good",good);
        }catch (ServiceException e){
            e.printStackTrace();
            map.put("code","500");
            map.put("message",e.getMessage());
        }
        return map;
    }

    /**
    * @Description: 向收藏表里存数据
    * @Param:  商品id，用户id
    * @return:  map
    * @Author: 王胜奔
     * exception:
    * @Date: 2019/10/19 0:09
    * Version: 1.0
    */
    @LogAnno(logType = LogTypeEnum.OPERATE_LOG,msg = "收藏")
    @RequestMapping("/saveUserConnection")
    @ResponseBody
    public Map saveUserConnection(Integer gid){
        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
        HttpSession session = ((ServletRequestAttributes) requestAttributes).getRequest().getSession();
        Integer uid = (Integer) session.getAttribute("userId");
        //System.out.println(session.getAttribute("userId"));
        //System.out.println("111111111111");
        Map result=new HashMap();
        try {
            UserCollection userCollection=new UserCollection();
            userCollection.setGid(gid);
            userCollection.setUid(uid);
            userConnectionService.saveUserConnection(userCollection);
            result.put("code","0");
            result.put("message","收藏成功");
        }catch (ServiceException e){
            e.printStackTrace();
            result.put("code","500");
            result.put("message",e.getMessage());
        }
        return result;
    }

    /**
    * @Description: 向提醒表里添加数据
    * @Param:  商品id，商品标题，开拍时间，结束时间，商品状态，用户手机号
    * @return:  map
    * @Author: 王胜奔
     * exception:
    * @Date: 2019/10/19 0:09
    * Version: 1.0
    */
    @RequestMapping("/saveSmsremind")
    @ResponseBody
    public Map saveSmsremind(Integer gid,String title,Date startTime,Date endTime,Integer goodState){
       Map result = new HashMap();
        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
        HttpSession session = ((ServletRequestAttributes) requestAttributes).getRequest().getSession();
        try {
           Smsremind smsremind = new Smsremind();
           smsremind.setsGtitle(title);
           //获取当前用户手机号
           Integer userId =(Integer)session.getAttribute("userId");
           System.out.println("userId:"+userId);
           User user=userService.getUserByUid(userId);
           String phone = user.getPhone();
           String email = user.getEmail();
           smsremind.setsUphone(phone);
           smsremind.setsEmail(email);
           smsremind.setsGstarttime(startTime);
           smsremind.setsGendtime(endTime);
           smsremind.setsGstate(goodState);
           smsremindService.saveSmsremind(smsremind);
           //往提醒表里添加数据就更新提醒人数
           goodService.modifyRemindNoByGid(gid);
           result.put("code","0");
           result.put("message","设置提醒成功");

       }catch (ServiceException e){
           e.printStackTrace();
           result.put("code","500");
           result.put("message",e.getMessage());
       }
        return result;
    }

    /**
    * @Description: 查询商品详情图片
    * @Param:  商品id
    * @return:  list
    * @Author: 王胜奔
     * exception:
    * @Date: 2019/10/19 10:26
    * Version: 1.0
    */
    @RequestMapping("/getPictures")
    @ResponseBody
    public List<GoodPictures> getPictures(Integer gid){
        return goodPicturesService.selectPics(gid);
    }

    /**
    * @Description: 查询出价记录和出价次数(分页）
    * @Param:  商品id
    * @return:  封装了出价次数和记录的dto
    * @Author: 王胜奔
    * @Date: 2019/10/19 10:47
    * Version: 1.0
    */
    @RequestMapping("/getBidRecords")
    @ResponseBody
    public Map getBidRecords(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,
                                      @RequestParam(value = "pageSize",defaultValue = "5") Integer pageSize,
                                        Integer gid){
        //BidRecordDTO bidRecordDTO=bidRecordService.getBidRecored(currentPage,pageSize,1);
        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
        HttpSession session = ((ServletRequestAttributes) requestAttributes).getRequest().getSession();
        Map result = new HashMap();
        try {
            List<BidRecord> list=bidRecordService.getBidRecoredsByGid(currentPage,pageSize,gid);
            PageInfo<BidRecord> pageInfo = new PageInfo<BidRecord>(list);
            Integer userId =(Integer)session.getAttribute("userId");
            //System.out.println("userId:"+userId);
            User user=userService.getUserByUid(userId);
            String account = user.getAccount();
            result.put("account",account);
            result.put("code","0");
            result.put("message",pageInfo);
        }catch (ServiceException e){
            e.printStackTrace();
            result.put("code","500");
            result.put("message",e.getMessage());
        }
        return result;
    }

    /**
    * @Description: 根据用户id、商品id、支付成功状态1来查询是否交了保证金
    * @Param:  gid:拍品id
    * @return:  map
    * @Author: 王胜奔
     * exception:
    * @Date: 2019/11/2 14:40
    * Version: 1.0
    */
    @RequestMapping("/getIsRendBond")
    @ResponseBody
    public Map getIsRendBond(Integer gid){
        Map map = new HashMap();
        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
        HttpSession session = ((ServletRequestAttributes) requestAttributes).getRequest().getSession();
        Integer uid =(Integer)session.getAttribute("userId");
        try {
            Orders orders = ordersService.getIsRendBond(gid,uid);
            map.put("code","0");
            map.put("message",orders);
        }catch (ServiceException e){
            e.printStackTrace();
            map.put("code","500");
            map.put("message",e.getMessage());
        }
        return map;
    }


//    //插入出价记录并修改前边的出价记录为出局
//    @RequestMapping("/modifyBidRecordState")
//    @ResponseBody
//    public Map modifyBidRecordState(Integer gid){
//        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
//        HttpSession session = ((ServletRequestAttributes) requestAttributes).getRequest().getSession();
//        Map result = new HashMap();
//        Integer userId =(Integer)session.getAttribute("userId");
//        try {
//            Date currentTime = new Date();
//            BidRecord bidRecord = new BidRecord();
//            bidRecord.setBidPrice(100);
//            bidRecord.setBidTime(currentTime);
//            bidRecord.setGid(gid);
//            bidRecord.setUid(userId);
//            bidRecord.setBidState("领先");
//            bidRecordService.saveSelective(bidRecord);
//            int brid=bidRecordService.getOutBrid(1,currentTime);
//            bidRecordService.modifyBidStateOutByBrid(brid);//修改前一条数据状态为出局
//            result.put("code","0");
//            result.put("message","出价成功");
//        }catch (ServiceException e){
//            e.printStackTrace();
//            result.put("code","500");
//            result.put("message",e.getMessage());
//        }
//
//        return result;
//    }

//    @RequestMapping("/showCheckPage")
//    public ModelAndView showCheckPasge(Integer gid){
//        ModelAndView modelAndView = new ModelAndView();
//        try {
//            Good good=goodService.getGoodByGid(gid);
//            modelAndView.setViewName("checkPage");
//            modelAndView.addObject("good",good);
//        }catch (ServiceException e){
//            e.printStackTrace();
//            modelAndView.setViewName("msg");
//            modelAndView.addObject("message",e.getMessage());
//        }
//        return modelAndView;
//    }



    /**
    * @Description: 发送验证码短信方法
    * @Param:  phone：手机号   msg：要发送的验证码
    * @return:  返回map，fegin的调用者可接到到是否发送成功
    * @Author: 王胜奔
     * exception:
    * @Date: 2019/11/1 15:55
    * Version: 1.0
    */
    @RequestMapping("/shortMsgRemind")
    @ResponseBody
    public Map shortMsgRemind(String phone,String msg){
        Map map = new HashMap();
        MobileAuthentication ma = new MobileAuthentication();
//        System.out.println("111111111:"+phone);
//        System.out.println("22222222:"+msg);
        try {
            if (phone!=null && !phone.equals("") && msg!=null && !msg.equals("")){
                ma.sendCode(phone,msg);
                map.put("msg","success!");
            }else {
                map.put("msg","error!");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }

    /**
    * @Description: 发送退还保证金邮箱方法
    * @Param:  phone：手机号   msg：要发送的信息
    * @return:  返回map，fegin的调用者可接到到是否发送成功
    * @Author: 王胜奔
     * exception:
    * @Date: 2019/11/1 15:55
    * Version: 1.0
    */
    @RequestMapping("/sellRefundBondMsg")
    @ResponseBody
    public Map sellRefundBondMsg(String mail,String msg,Integer type){
        Map map = new HashMap();
        System.out.println("111111111:"+mail);
        System.out.println("222222222:"+msg);
        try {
            if (mail!=null && !mail.equals("")){
                sendMail.sendEmailVertification(mail,msg,type);
                map.put("msg","success!");
            }else {
                map.put("msg","error!");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }
}
